<?php
/* @var $this BookController */
/* @var $model Book */
/* @var $form CActiveForm */
?>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl;?>/js/jquery-plugins/chosen/chosen.jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        KindEditor.ready(function(K) {
            window.editor = K.create('#kindeditor');
        });
        //$("#Book_typeid").chosen({allow_single_deselect: true});
    });
</script>

<div class="form">

    <?php $form=$this->beginWidget('CActiveForm', array(
        'id'=>'book-form',
        // Please note: When you enable ajax validation, make sure the corresponding
        // controller action is handling ajax validation correctly.
        // There is a call to performAjaxValidation() commented in generated controller code.
        // See class documentation of CActiveForm for details on this.
        'htmlOptions' => array('enctype' => 'multipart/form-data'),
        // 'enableClientValidation' => true,
        'clientOptions' => array(
            'validateOnSubmit' => true,  //在这个位置做验证
        ),
        'focus' => array($model,'bookname'),
    )); ?>

    <?php echo $form->errorSummary($model); ?>

    <div class="top-margin">
        <?php echo $form->labelEx($model,'bookname', array('class'=>'text-danger')); ?>
        <?php echo $form->textField($model,'bookname',array('size'=>45,'maxlength'=>45,'style'=>'width:500px','class'=>'form-control')); ?>
        <?php echo $form->error($model,'bookname'); ?>
    </div>

    <div>
        <?php echo $form->labelEx($model,'typeid', array('class'=>'text-danger')); ?>
        <?php echo CHtml::dropDownList(
                'Book[typeid]',
                $model->typeid,
                CHtml::listData(Type::model()->findAll(),'id','name')
            ); ?>
        <?php echo $form->error($model,'typeid'); ?>
    </div>

    <div class="top-margin">
        <?php echo $form->labelEx($model,'author', array('class'=>'text-danger')); ?>
        <?php echo $form->textField($model,'author',array('size'=>45,'maxlength'=>45,'style'=>'width:500px','class'=>'form-control')); ?>
        <?php echo $form->error($model,'author'); ?>
    </div>

    <!--
    <div class="top-margin">
        <?php echo $form->labelEx($model,'browsertimes'); ?>
        <?php echo $form->textField($model,'browsertimes'); ?>
        <?php echo $form->error($model,'browsertimes'); ?>
    </div>
    -->

    <div class="top-margin">
        <?php echo $form->labelEx($model,'abstract'); ?>
        <?php echo $form->textarea($model,'abstract',array('size'=>60,'maxlength'=>500,'class'=>'form-control')); ?>
        <?php echo $form->error($model,'abstract'); ?>
    </div>

    <!--
    <div class="top-margin">
        <?php echo $form->labelEx($model,'vote'); ?>
        <?php echo $form->textField($model,'vote'); ?>
        <?php echo $form->error($model,'vote'); ?>
    </div>
    -->

    <div class="top-margin">
        <?php echo $form->labelEx($model,'price', array('class'=>'text-danger')); ?>
        <?php echo $form->textField($model,'price',array('style'=>'width:500px','class'=>'form-control')); ?>
        <?php echo $form->error($model,'price'); ?>
    </div>

    <div class="top-margin">
        <?php echo $form->labelEx($model,'picture'); ?>
        <?php if($model->picture): ?>
            <?php echo CHtml::encode($model->picture); ?>
        <?php endif?>
        <?php echo $form->filefield($model,'picture',array('size'=>60,'maxlength'=>300,'style'=>'width:500px')); ?>
        <?php echo $form->error($model,'picture'); ?>
    </div>

    <!--
    <div class="row">
        <?php echo $form->labelEx($model,'file'); ?>
        <?php echo $form->filefield($model,'file',array('size'=>60,'maxlength'=>300)); ?>
        <?php echo $form->error($model,'file'); ?>
    </div>
    -->

    <div>
        <?php echo $form->labelEx($model,'content'); ?>
        <textarea name="Book[content]" id="kindeditor" class='form-control'><?php echo $model->content; ?></textarea>
    </div>
    <!--
    <div class="row">
        <?php echo $form->labelEx($model,'content'); ?>
        <?php echo $form->textArea($model,'content',array('rows'=>6, 'cols'=>50)); ?>
        <?php echo $form->error($model,'content'); ?>
    </div>
    <div class="row buttons">
    -->

    <hr/>
    <div class="text-right">
        <?php echo CHtml::submitButton($model->isNewRecord ? '立即创建' : '保存修改', array('class'=>'btn btn-action')); ?>
    </div>

</div><!-- form -->
<?php $this->endWidget(); ?>
